Add transaction support via sessions - #5
Merged
Conversation
DavidBadura
force-pushed
the
add-transaction-support
branch
from
August 29, 2026 09:13
bd6cf09 to
97cdac0
Compare
DavidBadura
force-pushed
the
add-transaction-support
branch
from
August 29, 2026 09:17
97cdac0 to
e59abdd
Compare
DanielBadura
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds opt-in transaction support on top of the existing single-connection model.
Client::startSession()returns aSessionthat managesBEGIN,COMMIT, andROLLBACKon the client's PDO connection. Its API mirrorsmongodb/mongodbwithstartTransaction,commitTransaction,abortTransaction, andwithTransaction, allowing existing MongoDB-oriented code to keep working with minimal changes.withTransactionhandles commit and rollback automatically and retries transient failures such as serialization errors and deadlocks a limited number of times. MongoDB'sreadConcernis mapped to the corresponding PostgreSQL isolation level.Because all operations already use the single PDO connection owned by the client, an active transaction automatically covers subsequent operations, regardless of whether the
sessionoption is explicitly passed. Sessions from a different client are not validated yet; this is documented as a current limitation.Two related changes are included:
bulkWritenow joins an existing transaction instead of attempting to open a nested one, which PDO does not support.QueryExceptionnow exposes the SQLSTATE so the transaction retry logic can identify transient database errors.Nested transactions are rejected, matching MongoDB's behavior.